package org.people.democracy;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.google.analytics.tracking.android.EasyTracker;

@SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
        String myURL = "http://www.ustream.tv/channel/longson3000";         
        WebView myBrowser=(WebView)findViewById(R.id.mybrowser);  
  
        WebSettings websettings = myBrowser.getSettings();  
        websettings.setSupportZoom(true);  
        websettings.setBuiltInZoomControls(true);   
        websettings.setJavaScriptEnabled(true);  
               
    	myBrowser.setWebViewClient(new WebViewClient());
        myBrowser.loadUrl(myURL);
	}

	@Override
	public void onBackPressed() {
		//final String liveURL = "http://stlive.maxorz.com/";
		final String liveURL = "https://ethercalc.org/static/proxy/hackpad/";
	    new AlertDialog.Builder(this)
	        .setTitle(R.string.dialog_exit_title)
	        .setMessage(R.string.dialog_exit_content)
	        .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
		        @Override
		        public void onClick(DialogInterface dialog, int which) {
		            finish();    
		        }	
		    })
		    .setNeutralButton(R.string.dialog_commet, new DialogInterface.OnClickListener() {
		        @Override
		        public void onClick(DialogInterface dialog, int which) {
		        	startActivity(new Intent(Intent.ACTION_VIEW, 
		        			Uri.parse(liveURL)));
		        }	
		    })				    
		    .setNegativeButton(R.string.dialog_cancel, null)
		    .show();
	}
	
	
	/*
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	*/

	@Override
	public void onStart() {
	  super.onStart();
	  EasyTracker.getInstance(this).activityStart(this);  // Add this method.
	}	

	@Override
	public void onStop() {
	  super.onStop();
	  EasyTracker.getInstance(this).activityStop(this);  // Add this method.
	}	
	
}
